package com.aiyige.page.photo.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.aiyige.page.photo.PhotoDataPage;
import com.aiyige.page.photo.model.Photo;
import com.aiyige.page.photo.model.PhotoDetail;

import java.util.LinkedList;
import java.util.List;

/**
 * Created by zhuyakun on 2017/12/20.
 */

public class PhotoDataPageAdapter extends FragmentPagerAdapter {
    PhotoDetail photoDetail;
    List<PhotoDataPage> photoDataPageList;

    public PhotoDataPageAdapter(FragmentManager fm, PhotoDetail photoDetail) {
        super(fm);
        this.photoDetail = photoDetail;
        photoDataPageList = new LinkedList<>();
        for (Photo photo : photoDetail.getPhotoList()) {
            photoDataPageList.add(PhotoDataPage.newInstance(photo));
        }
    }

    @Override
    public Fragment getItem(int position) {
        return photoDataPageList.get(position);
    }

    @Override
    public int getCount() {
        return photoDataPageList.size();
    }
}
